﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PCMSofCC;

namespace PCMSofCC.BLL
{
    public static class ScoreEntries
    {
        public static void AddScoreEntry(string _name, int _maxScore, string _criteria, string _remark)
        {
            PCMSofCCDataContext db = new PCMSofCCDataContext();
            var newScoreEntry = new ScoreEntry
            {
                Name = _name,
                Criteria = StringHelper.ReplaceNewLine(_criteria),
                MaxScore = _maxScore,
                Remark = StringHelper.ReplaceNewLine(_remark)
            };
            db.ScoreEntry.InsertOnSubmit(newScoreEntry);
            db.SubmitChanges();
        }

        public static IQueryable<ScoreEntry> GetChartEntries(int _chartId)
        {
            PCMSofCCDataContext db = new PCMSofCCDataContext();
            var q =
                from entry in db.ScoreEntry
                from es in entry.EntryBelongToChart
                where es.ChartId == _chartId
                select entry;
            return q;
        }

        public static IQueryable<ScoreEntry> GetAllEntries()
        {
            PCMSofCCDataContext db = new PCMSofCCDataContext();
            var q =
                from entry in db.ScoreEntry
                select entry;
            return q;
        }
    }
}
